import fetch from '@/utils/fetch'

export function apiGetProductList(listQuery) {
  return fetch({
    url: '/api/v1/product/list',
    method: 'get',
    params: listQuery
  })
}

export function apiGetProductById(productId) {
  return fetch({
    url: '/api/v1/product',
    method: 'get',
    params: {
      id: productId
    }
  })
}

export function apiAddProduct(productDto) {
  return fetch({
    url: '/api/v1/product',
    method: 'post',
    data: productDto
  })
}

export function apiUpdProduct(productDto) {
  return fetch({
    url: '/api/v1/product',
    method: 'put',
    data: productDto
  })
}

export function apiDelProduct(productId) {
  return fetch({
    url: '/api/v1/product',
    method: 'delete',
    params: {
      id: productId
    }
  })
}

export function apiExport (listQuery) {
  return fetch({
    url: '/api/v1/product/export',
    method: 'post',
    data: listQuery,
    responseType: 'arraybuffer'
  })
}


export function apiGetPrice(listQuery) {
  return fetch({
    url: '/api/v1/product/price',
    method: 'get',
    params: listQuery
  })
}
